#ifndef HTTPSCLIENT_H
#define HTTPSCLIENT_H
#include <QString>
#include <QByteArray>
#include <QNetworkAccessManager>
#include <QNetworkReply>


class HttpClient : public QObject
{
    Q_OBJECT

public:
    enum HttpMethod{
        POST = 0,
        GET, DELETE, PUT
    };
    Q_ENUM(HttpMethod)

    HttpClient();
    ~HttpClient();

    void doRequest(HttpClient::HttpMethod method, QString& url, QString postData="");
    void doRequestGet(QString& url);
    void doRequestPost(QString& url,QString postData);
    QString Html2Text(QString htmlString);

private slots:
    void postFinishSlot();
    void httpErrorSlot(QNetworkReply::NetworkError err);

signals:
    void postFinish(QString url,int statusCode, QByteArray& response);
    void httpError(QNetworkReply::NetworkError err);

private:
    QNetworkAccessManager *mAccessManager;
    QNetworkReply *mReply;
};

#endif // HTTPSCLIENT_H
